<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    hello
    <button id="submit">提交1</button>
    <button id="submit2">提交2</button>
    <script src="https://cdn.bootcss.com/axios/0.18.0/axios.min.js"></script>
    <script>
        // 方法一
        document.getElementById("submit").onclick = function () {
            // var data = JSON.stringify({"num":"123"})
            var data = { "num": "123" }
            axios.post("http://127.0.0.1:5000/download", data)
        }
        // 方法二
        document.getElementById("submit2").onclick = function () {
            // var data = JSON.stringify({"num":"123"})
            var data = [{ "num": "123" }]
            var temp = document.createElement("form");
            temp.action = "http://127.0.0.1:5000/download";
            temp.method = "post";
            temp.style.display = "none";
            for (var x in data) {
                var opt = document.createElement("textarea");
                opt.name = x;
                opt.value = d[x];
                // alert(opt.name)      
                temp.appendChild(opt);
            }
            document.body.appendChild(temp);
            temp.submit();
            return temp;
        }
    </script>
</body>

</html>